package com.zwf.mapper;

import com.zwf.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

/**
 * @Author zwf
 * @date 2024/2/5 23:31
 */
@Mapper
public interface UserMapper {

    /**
     * 根据openId查询表中是否存在该用户
     * @param openId
     */
    @Select("select * from user where openid=#{openId}")
    User queryByOpenId(String openId);

    /**
     * 向表中添加新用户
     * @param user
     */
    void add(User user);

    /**
     * 根据id查用户
     * @param userId
     * @return
     */
    @Select("select * from user where id=#{userId}")
    User getById(Long userId);

    /**
     * 动态统计用户数
     * @param map
     * @return
     */
    Integer countByMap(Map map);
}
